﻿using System;
using CoreRay;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CoreRay.Testing
{
    /// <summary>
    /// This is a test class for IndexBufferTest and is intended
    /// to contain all IndexBufferTest Unit Tests
    /// </summary>
    [TestClass]
    public class IndexBufferTest
    {
        /// <summary>
        /// Write test.
        /// </summary>
        [TestMethod]
        public void WriteTest()
        {
            // Setup
            IndexBuffer indexBuffer = new IndexBuffer();
            indexBuffer.Write(3);
            indexBuffer.Write(6);
            indexBuffer.Write(2);

            // Execute
            int expected = 6;
            int actual = indexBuffer.GetVertexIndex(1);

            // Verify
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        /// GetIndex with a wrong offset test.
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void GetIndexWrongOffsetTest()
        {
            // Setup
            IndexBuffer indexBuffer = new IndexBuffer();
            indexBuffer.Write(3);
            indexBuffer.Write(6);
            indexBuffer.Write(2);

            // Execute
            indexBuffer.GetVertexIndex(5);
        }
    }
}
